home *** CD-ROM | disk | FTP | other *** search
Wrap
'************************************************************************** '* TextBridge 1.0 Microsoft Setup Script '************************************************************************** ''$DEFINE DEBUG ''Define for script development/debugging '$INCLUDE 'setupapi.inc' '$INCLUDE 'msdetect.inc' '' KLUDGE! Took this really useful function from the debug ones, so '' I can validate a path! DECLARE FUNCTION FValidFATDir LIB "mscomstf.dll" (szFile$) AS INTEGER ''Dialog ID's CONST WELCOME = 100 CONST LICENSE = 110 CONST ASKQUIT = 200 CONST DESTPATH = 300 CONST EXITFAILURE = 400 CONST EXITQUIT = 600 CONST EXITSUCCESS = 700 CONST OPTIONS = 800 CONST APPHELP = 900 CONST BADPATH = 6400 CONST DIREXISTS = 1201 CONST LANGHELP = 1200 CONST LANGPACKS = 1100 CONST NOLANGS = 1300 CONST NOSPACE = 1400 CONST DISKHELP = 1600 ''Bitmap ID CONST LOGO = 1 GLOBAL DEST$ ''Default destination directory. GLOBAL SrcDir$ '' STF_SRCDIR. GLOBAL DEFLANG$ ''Default Language id DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING DECLARE SUB AddNewVerSectionToCopyList (szSection$, szSrcDir$, szDstDir$) DECLARE SUB AddNewVerSectionKeyToCopyList (szSection$, szKey$, szSrcDir$, szDstDir$) INIT: CUIDLL$ = GetSymbolValue("STF_CWDDIR") + "mscuistf.dll" ''Custom user interface dll HELPPROC$ = "FHelpDlgProc" ''Help dialog procedure SrcDir$ = GetSymbolValue("STF_SRCDIR") SetBitmap CUIDLL$, LOGO SetTitle "TextBridge OCR Setup Utility" szInf$ = GetSymbolValue("STF_SRCINFPATH") IF szInf$ = "" THEN szInf$ = GetSymbolValue("STF_CWDDIR") + "TXBRIDGE.INF" END IF ReadInfFile szInf$ DEST$ = "C:\TXBRIDGE" '$IFDEF DEBUG i% = SetSizeCheckMode(scmOnIgnore) '' could use scmOff; def = scmOnFatal WinDrive$ = MID$(GetWindowsDir, 1, 1) IF IsDriveValid(WinDrive$) = 0 THEN i% = DoMsgBox("Windows drive ('"+WinDrive$+"') is not a valid drive.", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK) GOTO QUIT END IF '$ENDIF ''DEBUG WELCOME: '' '' Show the max window first! '' a%=ShowWindow( HwndFrame, 3) sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$) IF sz$ = "CONTINUE" THEN UIPop 1 ELSE GOSUB ASKQUIT GOTO WELCOME END IF LICENSE: sz$ = UIStartDlg(CUIDLL$, LICENSE, "FInfoDlgProc", 0,"") IF sz$ = "CONTINUE" THEN UIPop 1 ELSE UIPopAll ERROR STFQUIT END IF GETPATH: ClearCopyList SetSymbolValue "EditTextIn", DEST$ SetSymbolValue "EditFocus", "END" GETPATHL1: sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$) DEST$ = GetSymbolValue("EditTextOut") IF sz$ = "CONTINUE" THEN '* '* Make sure we have a valid path if we can. '* IF FValidFATDir(DEST$) = 0 THEN GOSUB BADPATH UiPop 1 GOTO GETPATHL1 END IF IF DoesDirExist(DEST$) THEN sz$ = UIStartDlg(CUIDLL$, DIREXISTS, "FQuitDlgProc", APPHELP, HELPPROC$) IF sz$ = "EXIT" THEN UIPop 1 GOTO GETPATHL1 END IF UiPop 1 ELSE CreateDir DEST$, cmoNone IF IsDirWritable(DEST$) = 0 THEN GOSUB BADPATH UiPop 1 GOTO GETPATHL1 END IF UIPop 1 END IF ELSEIF sz$ = "REACTIVATE" THEN GOTO GETPATHL1 ELSEIF sz$ = "BACK" THEN UIPop 1 GOTO INIT ELSE GOSUB ASKQUIT UiPop 1 GOTO GETPATH END IF ''For good measure... UiPopAll GETLANGS1: '' Here is where we should initialize the languages to default to English. LANGLST$ = "" DEFLANG$ = "0" GETLANGS: sz$ = UIStartDlg(CUIDLL$, LANGPACKS, "FCheckDlgProc", LANGHELP, HELPPROC$) IF sz$ = "CONTINUE" THEN szlang$ = GetListItem("CheckItemsOut", 1) IF szlang$ = "ON" THEN AddSectionKeyFileToCopyList "Langs", "1", SrcDir$, DEST$ + "\bin" LANGLST$ = LANGLST$ + "English, " DEFLANG$ = "1" END IF szlang$ = GetListItem("CheckItemsOut", 2) IF szlang$ = "ON" THEN AddSectionKeyFileToCopyList "Langs", "2", SrcDir$, DEST$ + "\bin" LANGLST$ = LANGLST$ + "French, " IF DEFLANG$ = "0" THEN DEFLANG$ = "4" END IF END IF szlang$ = GetListItem("CheckItemsOut", 3) IF szlang$ = "ON" THEN AddSectionKeyFileToCopyList "Langs", "3", SrcDir$, DEST$ + "\bin" LANGLST$ = LANGLST$ + "Italian, " IF DEFLANG$ = "0" THEN DEFLANG$ ="16" END IF END IF szlang$ = GetListItem("CheckItemsOut", 4) IF szlang$ = "ON" THEN AddSectionKeyFileToCopyList "Langs", "4", SrcDir$, DEST$ + "\bin" LANGLST$ = LANGLST$ + "German, " IF DEFLANG$ = "0" THEN DEFLANG$ = "2" END IF END IF szlang$ = GetListItem ("CheckItemsOut", 5) IF szlang$ = "ON" THEN AddSectionKeyFileToCopyList "Langs", "5", SrcDir$, DEST$ + "\bin" LANGLST$ = LANGLST$ + "Spanish, " IF DEFLANG$ = "0" THEN DEFLANG$ = "8" END IF END IF szlang$ = GetListItem ("CheckItemsOut", 6) IF szlang$ = "ON" THEN AddSectionKeyFileToCopyList "Langs", "6", SrcDir$, DEST$ + "\bin" LANGLST$ = LANGLST$ + "Portegese, " IF DEFLANG$ = "0" THEN DEFLANG$ = "1024" END IF END IF szlang$ = GetListItem ("CheckItemsOut", 7) IF szlang$ = "ON" THEN AddSectionKeyFileToCopyList "Langs", "7", SrcDir$, DEST$ + "\bin" LANGLST$ = LANGLST$ + "Dutch, " IF DEFLANG$ = "0" THEN DEFLANG$ = "32" END IF END IF szlang$ = GetListItem ("CheckItemsOut", 8) IF szlang$ = "ON" THEN AddSectionKeyFileToCopyList "Langs", "8", SrcDir$, DEST$ + "\bin" LANGLST$ = LANGLST$ + "Swedish, " IF DEFLANG$ = "0" THEN DEFLANG$ = "64" END IF END IF szlang$ = GetListItem ("CheckItemsOut", 9) IF szlang$ = "ON" THEN AddSectionKeyFileToCopyList "Langs", "9", SrcDir$, DEST$ + "\bin" LANGLST$ = LANGLST$ + "Finnish, " IF DEFLANG$ = "0" THEN DEFLANG$ = "256" END IF END IF szlang$ = GetListItem ("CheckItemsOut", 10) IF szlang$ = "ON" THEN AddSectionKeyFileToCopyList "Langs", "10", SrcDir$, DEST$ + "\bin" LANGLST$ = LANGLST$ + "Danish, " IF DEFLANG$ = "0" THEN DEFLANG$ = "512" END IF END IF szlang$ = GetListItem ("CheckItemsOut", 11) IF szlang$ = "ON" THEN AddSectionKeyFileToCopyList "Langs", "11", SrcDir$, DEST$ + "\bin" LANGLST$ = LANGLST$ + "Norwegian, " IF DEFLANG$ = "0" THEN DEFLANG$ = "128" END IF END IF IF LANGLST$ = "" THEN sz$ = UIStartDlg(CUIDLL$, NOLANGS, "FEditDlgProc", LANGHELP, HELPPROC$) UiPop 1 GOTO GETLANGS1 ENDIF '' Here we handle the other buttons on the dialog: UIPop 1 ELSEIF sz$ = "REACTIVATE" THEN GOTO GETLANGS ELSEIF sz$ = "BACK" THEN UIPopAll GOTO GETPATHL1 ELSE GOSUB ASKQUIT GOTO GETLANGS1 END IF '' NOW DO THE INSTALL!! '' GOSUB INSTALL '' '' QUIT: '' ON ERROR GOTO ERRQUIT IF ERR = 0 THEN dlg% = EXITSUCCESS ELSEIF ERR = STFQUIT THEN dlg% = EXITQUIT ELSE dlg% = EXITFAILURE END IF QUITL1: sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "") IF sz$ = "REACTIVATE" THEN GOTO QUITL1 END IF UIPop 1 END ERRQUIT: i% = DoMsgBox("Sources were corrupted. Please contact XIS Customer Support for assistance.", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND) END BADPATH: sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "") IF sz$ = "REACTIVATE" THEN GOTO BADPATH END IF UIPop 1 RETURN ASKQUIT: sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "") IF sz$ = "EXIT" THEN UIPopAll ERROR STFQUIT ELSEIF sz$ = "REACTIVATE" THEN GOTO ASKQUIT ELSE UIPop 1 END IF RETURN CHKSPACE: txspace& = GetCopyListCost("","","") IF txspace& = 0 THEN RETURN ELSE dspace& = GetFreeSpaceForDrive(DEST$) AddListItem "DriveStatusText", DEST$ AddListItem "DriveStatusText", STR$(txspace&) AddListItem "DriveStatusText", STR$(dspace&) sz$ = UIStartDlg(CUIDLL$, NOSPACE, "FCustInstDlgProc", DISKHELP, HELPPROC$) IF sz$ = "EXIT" THEN GOSUB ASKQUIT ELSE UiPop 1 GOTO GETPATH ENDIF ENDIF RETURN '** '** Purpose: '** Builds the copy list and performs all installation operations. '** Arguments: '** none. '** Returns: '** none. '************************************************************************* INSTALL: CreateDir DEST$, cmoNone CreateDir DEST$ + "\bin", cmoNone '' CreateDir DEST$ + "\datacopy", cmoNone '' CreateDir DEST$ + "\drivers", cmoNone '' CreateDir DEST$ + "\ddemacs", cmoNone OpenLogFile MakePath(DEST$, "TXBRIDGE.LOG"), 0 WriteToLogFile "" WriteToLogFile " User chose as destination directory: '" + DEST$ + "'" WriteToLogFile "" WriteToLogFile "May have had to create the directory: " + DEST$ WriteToLogFile "" WriteToLogFile "Languages Selected are: " + LANGLST$ AddSectionFilesToCopyList "Files", SrcDir$, DEST$ + "\bin" windir$ = GetWindowsDir() tmp$ = MakePath(windir$,"pixtran") AddNewVerSectionToCopyList "Scanner", SrcDir$, tmp$ tmp$ = MakePath(windir$,"system") AddNewVerSectionToCopyList "Windows Sys", SrcDir$, tmp$ '' AddSectionFilesToCopyList "DDEMACS", SrcDir$, DEST$ + "\ddemacs" AddSectionFilesToCopyList "DOC", SrcDir$, DEST$ '' '' Add the datacopy files to the copylist. '' '' AddSectionFilesToCopyList "DATACOPY", SrcDir$, DEST$ + "\datacopy" '' '' Before doing the install, lets see if they have the space to do it. GOSUB CHKSPACE CopyFilesInCopyList '' Now, delete their .ini file if it exists. windir$ = GetWindowsDir() ini$ = MakePath(windir$,"TXBRIDGE.INI") IF DoesFileExist(ini$, femExists) = 1 THEN RemoveFile ini$, cmoNone END IF '' Make the new .ini file, and put in the new root value for the '' DDE stuff, and set a default language. CreateIniKeyValue ini$, "txbridge", "scanner type", "TWAIN", cmOverwrite CreateIniKeyValue ini$, "txbridge", "intl", "1", cmOverwrite CreateIniKeyValue ini$, "txbridge", "memory", "native", cmOverwrite CreateIniKeyValue ini$, "txbridge", "TWAINUI", "ON", cmOverwrite CreateIniKeyValue ini$, "txbridge", "INVERT", "2", cmOverwrite CreateIniKeyValue ini$, "txbridge", "cmdLine", "1", cmOverwrite CreateIniKeyValue ini$, "txbridge", "ADF", "Off", cmoOverwrite CreateIniKeyValue ini$, "txbridge", "root", DEST$, cmoOverwrite CreateIniKeyValue ini$, "txbridge", "Language", DEFLANG$, cmOverwrite CreateIniKeyValue ini$, "txbridge", "File", "File", cmOverwrite CreateIniKeyValue ini$, "txbridge", "Edit", "Edit", cmOverwrite CreateIniKeyValue ini$, "txbridge", "Paste", "Paste", cmOverwrite CreateIniKeyValue ini$, "txbridge", "Exit", "Exit", cmOverwrite CreateProgmanGroup "TextBridge OCR", "", cmoNone CreateProgmanItem "TextBridge OCR", "TextBridge", DEST$ + "\bin\" + "txbridge.exe", "", cmoOverwrite CreateProgmanItem "TextBridge OCR", "Scanner Setup", DEST$ + "\bin\" + "setscan.exe", "", cmoOverwrite CreateProgmanItem "TextBridge OCR", "Release Notes", DEST$ + "\" + "relnote.wri","", cmoOverwrite CreateProgmanItem "TextBridge OCR", "TextBridge Application Server", DEST$ + "\bin\" + "tbmenu.exe","",cmoOverwrite CreateProgmanItem "TextBridge OCR", "TextBridge Pro -- How to Upgrade", DEST$ + "\bin\" + "upmenu16.hlp","", cmoOverwrite ShowProgmanGroup "TextBridge OCR", 1, cmoNone CloseLogFile RETURN '** '** Purpose: '** Appends a file name to the end of a directory path, '** inserting a backslash character as needed. '** Arguments: '** szDir$ - full directory path (with optional ending "\") '** szFile$ - filename to append to directory '** Returns: '** Resulting fully qualified path name. '************************************************************************* FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING IF szDir$ = "" THEN MakePath = szFile$ ELSEIF szFile$ = "" THEN MakePath = szDir$ ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN MakePath = szDir$ + szFile$ ELSE MakePath = szDir$ + "\" + szFile$ END IF END FUNCTION SUB AddNewVerSectionToCopyList (szSection$, szSrcDir$, szDstDir$) STATIC MakeListFromSectionKeys "VersionList", szSection$ iVerListLen% = GetListLength("VersionList") FOR i% = 1 TO iVerListLen% STEP 1 key$ = GetListItem("VersionList", i%) IF key$ = "" THEN rtn% = DoMsgBox("There is an error in the {" + szSection$ + "} section. You must set REFKEY equal to the filename.ext", "Layout ERROR", MB_TASKMODAL+MB_ICONHAND+MB_OK) RETURN END IF AddNewVerSectionKeyToCopyList szSection$, key$, szSrcDir$, szDstDir$ NEXT i% END SUB SUB AddNewVerSectionKeyToCopyList (szSection$, szKey$, szSrcDir$, szDstDir$) STATIC IF szKey$ = "" THEN rtn% = DoMsgBox("szKey$ should not be equal to NULL", "Error in AddNewVerSectionKeyToCopyList", MB_TASKMODAL+MB_ICONHAND+MB_OK) RETURN END IF IF szSection$ = "" THEN rtn% = DoMsgBox("szSection$ should not be equal to NULL", "Error in AddNewVerSectionKeyToCopyList", MB_TASKMODAL+MB_ICONHAND+MB_OK) RETURN END IF IF szSrcDir$ = "" THEN rtn% = DoMsgBox("szSrcDir$ should not be equal to NULL", "Error in AddNewVerSectionKeyToCopyList", MB_TASKMODAL+MB_ICONHAND+MB_OK) RETURN END IF IF szDstDir$ = "" THEN rtn% = DoMsgBox("szDstDir$ should not be equal to NULL", "Error in AddNewVerSectionKeyToCopyList", MB_TASKMODAL+MB_ICONHAND+MB_OK) RETURN END IF fileName$ = GetSectionKeyFilename(szSection$, szKey$) sysFileName$ = MakePath(szDstDir$, fileName$) ourVer$ = GetSectionKeyVersion(szSection$, szKey$) IF ourVer$ = "" THEN '''''''''''''''''''''''''''''''''''''' '' Use File dates to check versions '' '''''''''''''''''''''''''''''''''''''' ourDate$ = GetSectionKeyDate(szSection$, szKey$) sysDate$ = GetDateOfFile (sysFileName$) '$IFDEF DEBUG rtn% = DoMsgBox("Our file ("+sysFileName$+") has date " + ourDate$ + " and the system has date " + sysDate$, "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK) '$ENDIF ''DEBUG IF GetYearFromDate(sysDate$) < GetYearFromDate(ourDate$) THEN '$IFDEF DEBUG rtn% = DoMsgBox("Adding ("+fileName$+") to hard disk ", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK) '$ENDIF ''DEBUG AddSectionKeyFileToCopyList szSection$, szKey$, szSrcDir$, szDstDir$ ELSEIF GetYearFromDate(sysDate$) = GetYearFromDate(ourDate$) THEN IF GetMonthFromDate(sysDate$) < GetMonthFromDate(ourDate$) THEN '$IFDEF DEBUG rtn% = DoMsgBox("Adding ("+fileName$+") to hard disk ", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK) '$ENDIF ''DEBUG AddSectionKeyFileToCopyList szSection$, szKey$, szSrcDir$, szDstDir$ ELSEIF GetMonthFromDate(sysDate$) = GetMonthFromDate(ourDate$) THEN IF GetDayFromDate(sysDate$) < GetDayFromDate(ourDate$) THEN '$IFDEF DEBUG rtn% = DoMsgBox("Adding ("+fileName$+") to hard disk ", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK) '$ENDIF ''DEBUG AddSectionKeyFileToCopyList szSection$, szKey$, szSrcDir$, szDstDir$ END IF END IF END IF ELSE ''''''''''''''''''''''''''''''''''''''''''''''' '' Use Version information to check versions '' ''''''''''''''''''''''''''''''''''''''''''''''' sysVer$ = GetVersionOfFile (sysFileName$) IF sysVer$ <> ourVer$ THEN '$IFDEF DEBUG rtn% = DoMsgBox("Our file ("+fileName$+") has version " + ourVer$ + " and the system has version " + sysVer$, "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK) '$ENDIF ''DEBUG IF GetVersionNthField(sysVer$, 1) < GetVersionNthField(ourVer$, 1) THEN AddSectionKeyFileToCopyList szSection$, szKey$, szSrcDir$, szDstDir$ ELSEIF GetVersionNthField(sysVer$, 1) = GetVersionNthField(ourVer$, 1) THEN IF GetVersionNthField(sysVer$, 2) < GetVersionNthField(ourVer$, 2) THEN AddSectionKeyFileToCopyList szSection$, szKey$, szSrcDir$, szDstDir$ ELSEIF GetVersionNthField(sysVer$, 2) = GetVersionNthField(ourVer$, 2) THEN IF GetVersionNthField(sysVer$, 3) < GetVersionNthField(ourVer$, 3) THEN AddSectionKeyFileToCopyList szSection$, szKey$, szSrcDir$, szDstDir$ ELSEIF GetVersionNthField(sysVer$, 3) = GetVersionNthField(ourVer$, 3) THEN IF GetVersionNthField(sysVer$, 4) < GetVersionNthField(ourVer$, 4) THEN AddSectionKeyFileToCopyList szSection$, szKey$, szSrcDir$, szDstDir$ END IF END IF END IF END IF END IF END IF END SUB